import Vue from 'vue'

// 箭头筛选
Vue.prototype.SortData = function(res) {
	// console.log(res,'排序')
	var key = res.key,//当前key 值
		keySort = res.keySort, //当前筛选key值
		order = res.order, //当前类型 0:正序 1:倒序
		this_keySortValue = res.this_keySortValue, //data 当前的筛选key值
		this_topIconColor = res.this_topIconColor, //data 当前  正序值
		this_bottomIconColor = res.this_bottomIconColor,// data 当前 倒序值
		this_order = res.this_order, //data 定义的类型当前的值 0:正序 1:倒序
		this_keySortFlag = res.this_keySortFlag; //data  当前 的 keySortFlag 值
	if (this_keySortValue !== key) {
		this_topIconColor = this_bottomIconColor = '#c0c4cc'
		this_keySortValue = key
	}
	var field = '' ////接口需要传的 标题key  值 
	field = keySort
	if (order === this_order) {
		this_keySortFlag = false
		this_order = ''
		field = ''
	} else {
		this_keySortFlag = true
		this_order = Number(order)
	}
	// order 0正序 1 倒序
	if (Number(order) === 0) {
		this_topIconColor =
			this_topIconColor === '#c0c4cc' ? '#DFB771' : '#c0c4cc'
		if (this_topIconColor === '#DFB771') {
			this_bottomIconColor = '#c0c4cc'
		}
	} else {
		this_bottomIconColor =
			this_bottomIconColor === '#c0c4cc' ? '#DFB771' : '#c0c4cc'
		if (this_bottomIconColor === '#DFB771') {
			this_topIconColor = '#c0c4cc'
		}
	}
	// 无排序获取所有
	if (order === -1) {
		// console.log('无排序获取所有')
		field = ''
		this_order = ''
		this_keySortValue = ''
	}
	var obj = {
		key: key,//当前key 值
		keySort: keySort, //筛选key值
		order: this_order, //当前类型 0:正序 1:倒序
		keySortValue: this_keySortValue, //当前的筛选key值
		topIconColor: this_topIconColor, //定义 正序值
		bottomIconColor: this_bottomIconColor,// 倒序值
		keySortFlag: this_keySortFlag, //data定义 的 keySortFlag
		field: field
	}
	return obj
}

